package com.example.file_explorer.config;

import cn.dev33.satoken.exception.NotLoginException;
import com.example.file_explorer.result.Code;
import com.example.file_explorer.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/** 全局异常处理*/
@RestControllerAdvice
public class GlobalException {

    // 拦截未登录异常
    @ExceptionHandler(NotLoginException.class)
    public Result<Object> handlerException(NotLoginException e) {
        return Result.error(Code.NOT_LOGIN.getCode(), "未登录");
    }

}
